/** m2settings is a GUI to configure Maven 2 settings.xml 
 * 
 *  Copyright (C) 2007 Regis Decamps <decamps@users.sf.net>
 * 
 *  This file is part of m2settings.
 *
 *  m2settings is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version. 
 *
 *  Foobar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *  or read it online http://www.gnu.org/licenses/gpl.txt
 *
 **/
/*
 * MyProxy.java
 *
 * Created on April 25, 2007, 2:29 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package info.decamps.m2settings.beans;

import info.decamps.m2settings.model.Proxy;
import org.apache.commons.lang.StringUtils;

/**
 *
 * @author regis
 */
public class MyProxy {
    private Proxy proxy;
    /** Creates a new instance of MyProxy */
    public MyProxy() {
        this.proxy=new Proxy();
        //set default values
        proxy.setActive(true);
        proxy.setProtocol("http");
    }
    public MyProxy(Proxy proxy) {
        this.proxy=proxy;
    }
    public String getId() {
        return proxy.getId();
    }
    public boolean isActive() {
        return proxy.getActive();
    }
    public String getProtocol() {
        return proxy.getProtocol();
    }
    
    public Proxy getProxy() {
        return proxy;
    }
    public String getHost() {
        return proxy.getHost();
    }
    public int getPort() {
        return proxy.getPort();
    }
    public String getUsername() {
        return proxy.getUsername();
    }
    public String getPassword() {
        return proxy.getPassword();
    }
    public String getNonProxyHosts() {
        return proxy.getNonProxyHosts();
    }
    public void setId(String id) {
        proxy.setId(id);
    }
    public void setActive(boolean active) {
        proxy.setActive(active);
    }
    public void setProtocol(String protocol) {
        if (StringUtils.isBlank(protocol))
            protocol=null;
        proxy.setProtocol(protocol);
    }
    
    public void setHost(String host) {
        if (StringUtils.isBlank(host))
            host=null;
        proxy.setHost(host);
    }
    public void setPort(String port) {
        proxy.setPort(Integer.parseInt(port));
    }
    public void setPort(int port) {
        proxy.setPort(port);
    }
    public void setUsername(String username) {
        if (StringUtils.isBlank(username))
            username=null;
        proxy.setUsername(username);
    }
    public void setNonProxyHosts(String hostList) {
        if (StringUtils.isBlank(hostList))
            hostList=null;
        proxy.setNonProxyHosts(hostList);
    }
    public void setPassword(String password) {
        if (StringUtils.isBlank(password) )
            password=null;
        proxy.setPassword(password);        
    }
    
    public void setPassword(char[] c) {
        String s=new String(c);
        setPassword(s);
    }
}